#ifndef POLYNOMIAL_H_
#define POLYNOMIAL_H_

#include<vector>
#include<iostream>
#include<fstream>
using namespace std;

template<int order>
class polynomial
{
private:
    vector<double> coeff;   // e.g. {0,1,2} <-> x+2x^2
public:
    polynomial(){ coeff.resize(order + 1); }
    polynomial(vector<double> _coeff): coeff(_coeff){};
    ~polynomial(){};
    double get_value_at_x(double x);
    void print_poly();
};

// 给定两个节点, 节点对应函数值和二阶导数值, 求出3次多项式
polynomial<3> cubic_0_2_val(double a, double b,
                        double fa, double fb,
                        double Ma, double Mb);

// 给定两个节点和节点对应函数值, 求出1次多项式(线性函数)
polynomial<1> linear_0_val(double a, double b,
                        double fa, double fb);

#endif